# -*- coding: utf-8 -*-
import queue
class Pipe(object):
    '''
    # input a Req
    # a Req consists of 3 parts and id:
    # _id
    # unit_info
        ->start
        {'unit_name':'SampleJudge'}
    # data_info
        ->start
        {
            "dataset_from_commit":{
            "dataset_usage":"dataset_from_commit",
            "field_name_list"==['uid','pid','tid','ans'],
            "uid_pid_tid_ans_list":[{'uid':1,'pid':1,'tid':1,'ans':1},{...}]
            }
        }
        -->after Fetcher
        {
            "dataset_from_commit":{
                "dataset_usage":"dataset_from_commit",
                "field_name_list"==['uid','pid','tid','ans'],
                "uid_pid_tid_ans_list":[{'uid':1,'pid':1,'tid':1,'ans':1},{...}]
            }
            -------add in Fetcher
            "dataset_uid_history_ans":{
                "dataset_usage":"dataset_to_unit",
                "field_name_list"==['uid','pid','tid','ans'],
                "data_list":[
                    "uid":5520,
                    #todo convert a dict {'pid':1,'tid':1,'ans':1} to a hash
                    "pid_tid_ans_list":[{'pid':1,'tid':1,'ans':1},{'pid':1,'tid':1,'ans':-1},{...}]
                ]
            }
            "dataset_pid_history_ans":{
                "dataset_usage":"dataset_to_unit",
                "field_name_list":['uid','pid','tid','ans'],
                "data_list":[
                    "pid":1320,
                    "tid_uid_ans_list":[{'tid':1,'uid':1,'ans':1},{'tid':1,'uid':2,'ans':-1},{...}]
                ]
            }
            "dataset_tid_history_ans":{
                "dataset_usage":"dataset_to_unit",
                "field_name_list":['tid','pid','num'],P.S. num(12,23)-> 12 people is True 23 is False
                "tid":5130,
                "data_list":[
                    "tid":23
                    "pid_num_list":[{'pid':1,'num':(12,23)},{'pid':2,'num':(17,24)},{...}]
                }
            -------add in Fetcher
        }
    # fetch_info
        -->start
        {}
        -->after ReqFactory
        {"fetch_scheme":'SampleJudge',fetch_param_set:{uid_list':[1,2],'pid_list':[1,2],'tid_list':[1,2]}}
        -->after Fetcher
        {}
    '''
    def __init__(self,id=1,name="Pipe"):

        self._id=id
        self._name = name
        self.queue=queue.Queue()
    def put(self,item):
        self.queue.put(item)
    def get(self):
        return self.queue.get()
    def empty(self):
        return  self.queue.empty()
    def get_size(self):
        return self.queue.qsize()
if __name__ == "__main__":
    myPipe=Pipe()
    a=[1]
    myPipe.put(a)
    print (myPipe.get())